package com.training.java.core.homework07.collections.sets;

import java.util.HashSet;
import java.util.Set;

public class LaptopForHashSetDemo {

	public static void main(String[] args) {

		/*
		 * This program builds a HashSet of Laptop objects, but with equals()
		 * method overridden. Consequently, the duplicate check is in effect.
		 */

		// Create LaptopForHashSet objects with a few duplicates.
		LaptopForHashSet presario = new LaptopForHashSet("HP", "Presario", 4,
				100);
		LaptopForHashSet pavilion = new LaptopForHashSet("HP", "Pavilion", 6,
				200);
		LaptopForHashSet presario2 = new LaptopForHashSet("HP", "Presario", 6,
				200);
		LaptopForHashSet lenovo = new LaptopForHashSet("IBM", "Lenovo", 4, 200);
		LaptopForHashSet pavilion2 = new LaptopForHashSet("HP", "Pavilion", 10,
				800);

		// Check for equality:
		boolean laptopEqual;
		laptopEqual = presario.equals(pavilion);
		System.out.println("Are these two laptops equal? " + laptopEqual);

		laptopEqual = presario.equals(presario2);
		System.out.println("Are these two laptops equal? " + laptopEqual);

		Set<LaptopForHashSet> laptops = new HashSet<>(); // Create Treeset to
															// hold Laptop
															// objects

		// Add Laptop objects to TreeSet laptops.
		laptops.add(presario);
		// System.out.println("presario");
		laptops.add(pavilion);
		// System.out.println("pavilion");
		laptops.add(presario2);
		// System.out.println("presario2");
		laptops.add(lenovo);
		// System.out.println("lenovo");
		laptops.add(pavilion2);
		// System.out.println("pavilion2");

		System.out.println("");
		System.out.println("Printing laptops:");
		System.out.println("=================");
		for (LaptopForHashSet laptop : laptops) {
			System.out.println("Manufacturer = " + laptop.getManufacturer());
			System.out.println("Model = " + laptop.getModel());
			System.out.println("Memory = " + laptop.getMemory());
			System.out.println("Disk Capacity = " + laptop.getDiskCapacity());
			System.out.println("---------------------------------------");
		}
	}
}
